<template>
  <!-- 用户购买流量明细 -->
  <div style="padding: 10px;">
    <el-card>
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item :label="$t('用户id')">
          <el-input size="small" v-model="formInline.userId"></el-input>
        </el-form-item>
        <el-form-item :label="$t('用户邮箱')">
          <el-input size="small" v-model="formInline.email"></el-input>
        </el-form-item>
        <el-form-item :label="$t('状态')">
          <el-select size="small" v-model="formInline.status">
            <el-option :label="$t('无效')" :value="0"></el-option>
            <el-option :label="$t('有效')" :value="1"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('创建时间')">
          <el-date-picker
            value-format="yyyy-MM-dd HH:mm:ss"
            v-model="formInline.createTime"
            size="small"
            type="datetime"
            :placeholder="$t('选择日期时间')"
          ></el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button size="small" type="primary" @click="onSubmit">{{ $t('query') }}</el-button>
          <el-button size="small" type="warning" @click="reset">{{ $t('重置') }}</el-button>
        </el-form-item>
      </el-form>
    </el-card>
    <el-card style="margin-top: 10px;">
      <el-table v-loading="loading" style="font-size: 14px;" :data="tableData">
        <el-table-column prop="userId" :label="$t('用户id')"></el-table-column>
        <el-table-column prop="email" :label="$t('邮箱')"></el-table-column>
        <!-- <el-table-column prop="email" :label="$t('总资产')"></el-table-column>
        <el-table-column prop="email" :label="$t('购买流量包类型')"></el-table-column>
        <el-table-column prop="email" :label="$t('购买流量包个数')"></el-table-column>
        <el-table-column prop="status" :label="$t('状态')">
          <template #default="{ row }">
            {{ row.status?$t('有效'):$t('无效') }}
          </template>
        </el-table-column>
        <el-table-column prop="email" :label="$t('购买时间')"></el-table-column>-->
        <el-table-column prop="packageType" :label="$t('类型')">
          <template #default="{ row }">
            <span v-if="row.packageType===1">{{ $t('初级') }}</span>
            <span v-if="row.packageType===2">{{ $t('中级') }}</span>
            <span v-if="row.packageType===3">{{ $t('高级') }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="invalidFlowTotal" :label="$t('置灰总流量')"></el-table-column>
        <el-table-column prop="totalAmount" :label="`${$t('流量包总产值')}(CFP)`"></el-table-column>
        <!-- <el-table-column prop="predictAmountTo" :label="`${$t('每日预估产出')}(CFP)`">
          <template #default="{ row }">
            {{ row.predictAmountTo }}~{{row.predictAmountEnd  }}
          </template>
        </el-table-column>-->
        <el-table-column prop="flowNumber" :label="$t('购买数量')"></el-table-column>
        <el-table-column prop="purchaseTotalAmount" :label="`${$t('购买的流量包总产值')}(CFP)`"></el-table-column>
        <el-table-column prop="shareStatus" :label="$t('分享状态')">
          <template #default="{ row }">{{ row.shareStatus?$t('已分享'):$t('未分享') }}</template>
        </el-table-column>
        <el-table-column prop="status" :label="$t('状态')">
          <template #default="{ row }">{{ row.status?$t('有效'):$t('无效') }}</template>
        </el-table-column>
        <el-table-column prop="paymentType" :label="$t('支付方式')">
          <template #default="{ row }">{{ row.paymentType===1?'CFP':'' }}</template>
        </el-table-column>
        <el-table-column prop="purchaseTime" :label="$t('购买时间')"></el-table-column>
        <!-- <el-table-column prop="remark" :label="$t('描述')"></el-table-column>
        <el-table-column prop="createBy" :label="$t('创建人')"></el-table-column>-->
        <el-table-column prop="createTime" :label="$t('创建时间')"></el-table-column>
      </el-table>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        layout="total, prev, pager, next"
        :total="total"
      ></el-pagination>
    </el-card>
  </div>
</template>
    <script>
import { getflowdetailApi } from "@/api/appuser/userList";
export default {
  data() {
    return {
      page: {
        pageNum: 1,
        pageSize: 10
      },
      formInline: {
        userId: null,
        email: null,
        status: null,
        createTime: null
      },
      tableData: [],
      total: 0,
      loading: false
    };
  },
  created() {
    this.getflowdetail();
  },
  methods: {
    async getflowdetail() {
      this.loading = true;
      const res = await getflowdetailApi({
        ...this.page,
        ...this.formInline
      });
      console.log(res);
      this.total = res.total;
      this.tableData = res.rows;
      this.loading = false;
    },
    handleSizeChange(val) {
      this.page.pageSize = val;
      this.getflowdetail();
    },
    handleCurrentChange(val) {
      this.page.pageNum = val;
      this.getflowdetail();
    },
    onSubmit() {
      this.page = {
        pageNum: 1,
        pageSize: 10
      };
      console.log(this.formInline);
      this.getflowdetail();
    },
    reset() {
      this.page = {
        pageNum: 1,
        pageSize: 10
      };
      this.formInline = {
        userId: null,
        email: null,
        status: null,
        createTime: null
      };
      this.getflowdetail();
    }
  }
};
</script>
<style lang='' scoped>
</style>